package com.yuesystem.common;

/**
 * 基于ThreadLocal封装的工具类，用于保存和获取用户当前的ID
 */
public class BaseContext {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
    //保存当前线程的ID到threadLocal中，工具类，用static方法
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }

    //获取当前线程的ID
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}

